package com.medical.app.controller;

import com.medical.app.common.dto.ClinicRechargeDto;
import com.medical.app.common.dto.PatientDto;
import com.medical.app.common.dto.RechargeDto;
import com.medical.app.service.ClinicRechargeService;
import com.qf.medical.response.ResponseEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 1.根据患者id返回门诊充值页面数据
 * 2.返回患者所有的充值记录
 * 3.根据时间返回指定时间段的充值记录和卡内余额
 * 4.添加充值记录并回显余额
 * 5.切换就诊人回显关联微信id的所有患者
 */
@Api(tags = "客户端门诊充值接口Api在线文档")
@RestController
@RequestMapping("/clinicRecharge")
public class ClinicRechargeController {
    @Resource
    private ClinicRechargeService clinicRechargeService;

    @ApiOperation("返回页面数据")
    @GetMapping("/getRecharge")
    @ApiImplicitParam(name = "patientId", value = "患者id")
    public ResponseEntity<ClinicRechargeDto> getRecharge(@NotNull Long patientId) {
        return ResponseEntity.success(clinicRechargeService.getRecharge(patientId));
    }

    @ApiOperation("返回所有充值记录")
    @GetMapping("/getRechargeList")
    @ApiImplicitParam(name = "patientId", value = "患者id")
    public ResponseEntity<List<ClinicRechargeDto>> getRechargeList(@NotNull Long patientId) {
        return ResponseEntity.success(clinicRechargeService.getRechargeList(patientId));
    }

    @ApiOperation("返回指定时间段的充值记录")
    @PostMapping("/getListByDate")
    @ApiImplicitParams({@ApiImplicitParam(name = "patientId", value = "患者id"),
            @ApiImplicitParam(name = "startDate", value = "开始时间"),
            @ApiImplicitParam(name = "endDate", value = "结束时间")})
    public ResponseEntity<List<ClinicRechargeDto>> getListByDate(@RequestBody @NotNull ClinicRechargeDto clinicRechargeDto) {
        return ResponseEntity.success(clinicRechargeService.getListByDate(clinicRechargeDto));
    }

    @ApiOperation("添加充值记录并回显余额")
    @PostMapping("/addRecharge")
    @ApiImplicitParam(name = "rechargeDto", value = "充值Dto类")
    public ResponseEntity<Integer> addRecharge(@NotNull @RequestBody RechargeDto rechargeDto) {
        return ResponseEntity.success(clinicRechargeService.addRecharge(rechargeDto));
    }

    @ApiOperation("切换就诊人回显关联微信id的所有患者")
    @GetMapping("/getPatientList")
    @ApiImplicitParam(name = "weichatId", value = "微信id")
    public ResponseEntity<List<PatientDto>> getPatientList(@NotNull Integer weichatId) {
        return ResponseEntity.success(clinicRechargeService.getPatientList(weichatId));
    }
}
